/**
    @author: administrator
    @date:   2020/12/4
    @note:
**/
package main

import (
	"github.com/gin-gonic/gin"
	_ "github.com/go-sql-driver/mysql"
	"github.com/spf13/viper"
	"os"
	"websocket/commom"
)

var (
	Port = 7777
)

func main() {
	InitConfig()
	mysqldb := commom.InitDB()
	defer mysqldb.Close()
	defer commom.InitMongodb().Close()
	defer commom.InitRedis().Close()
	commom.GoDB()
	r := gin.Default()
	r = CollectRoute(r)
	port := viper.GetString("server.port")
	if port != "" {
		r.Run(":" + port)
	}
	r.Run()
}
func InitConfig() {
	workDir, _ := os.Getwd()
	viper.SetConfigName("application.yml")
	viper.SetConfigType("yml")
	viper.AddConfigPath(workDir + "/config")
	err := viper.ReadInConfig()
	if err != nil {

	}
}
